package com.daify.threadlearn.chapter01.order06;

import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.Future;

import static java.util.concurrent.TimeUnit.SECONDS;

/**
 * @author daify
 * @date 2019-06-11
 */
public class OutOfTime {

    public static void main(String[] args) throws InterruptedException {
        Timer timer = new Timer();
        timer.schedule(new ThrowTask(),1);
        SECONDS.sleep(1);
        timer.schedule(new ThrowTask(),1);
        SECONDS.sleep(5);
    }


    static class ThrowTask extends TimerTask {

        @Override
        public void run() {
            System.out.println("is error ");
            throw new RuntimeException();
        }
    }

}
